const
     maxn=200;
var
   ans,n,k,len:longint;
   work:array[0..maxn] of longint;
   g:array[0..maxn,0..maxn] of longint;
   link:array[0..maxn,0..maxn] of longint;
   opt1,opt2:array[0..maxn,0..maxn] of longint;
   v:array[0..maxn] of boolean;
   son,brother,up:array[0..maxn] of longint;
procedure init;
var
   i,a,b:longint;
begin
     readln(n,k);
     for i:=1 to n-1 do
      begin
           readln(a,b);
           g[a,b]:=1;
           g[b,a]:=1;
      end;
end;
procedure build(now:longint);
var
   i:longint;
   chk:boolean;
begin
     v[now]:=true;
     chk:=false;
     for i:=1 to n do
     if (g[now,i]=1)and(not(v[i])) then
      begin
           if not(chk) then
            begin
                 chk:=true;
                 son[now]:=i;
            end;
           inc(link[now,0]);
           link[now,link[now,0]]:=i;
           brother[up[now]]:=i;
           up[now]:=i;
           build(i);
      end;
end;
procedure work1(now:longint);
var
   i:longint;
begin
     for i:=link[now,0] downto 1 do work1(link[now,i]);
     inc(len);
     work[len]:=now;
end;
procedure TreeDp;
var
   i,j,now,min,m:longint;
begin
     for i:=1 to n do
       for j:=0 to k do
      begin
           opt1[i,j]:=maxlongint;
           opt2[i,j]:=maxlongint;
      end;
     for now:=1 to len do
     begin
           if son[work[now]]=0 then opt1[work[now],1]:=0
                               else
           for i:=0 to k-1 do opt1[work[now],i+1]:=opt2[son[work[now]],i];
        if opt1[work[now],k]<>maxlongint then
        begin
           if now=len then
           begin
                if opt1[work[now],k]<ans then ans:=opt1[work[now],k];
           end
           else
           begin
                if opt1[work[now],k]+1<ans then ans:=opt1[work[now],k]+1;
           end;
        end;
         if brother[work[now]]=0 then
                begin
                     opt2[work[now],0]:=1;
                     for j:=1 to k do opt2[work[now],j]:=opt1[work[now],j];
                end
                else
                begin
                     opt2[work[now],0]:=opt2[brother[work[now]],0]+1;
                     for i:=1 to k do
                      if opt2[brother[work[now]],i]<>maxlongint then
                      opt2[work[now],i]:=opt2[brother[work[now]],i]+1;
                     for i:=1 to k do
                  begin
                       min:=opt2[work[now],i];
                       for m:=1 to i do
                          if (opt2[brother[work[now]],i-m]<>maxlongint)and
                             (opt1[work[now],m]<>maxlongint) then
                             begin
                                 if min>opt2[brother[work[now]],i-m]+opt1[work[now],m] then
                                    min:=opt2[brother[work[now]],i-m]+opt1[work[now],m];
                             end;
                       opt2[work[now],i]:=min;
                  end;
                end;
     end;
end;
begin
     ans:=maxlongint;
     fillchar(v,sizeof(v),false);
     init;
     build(1);
     work1(1);
     TreeDp;
     writeln(ans);
end.
